package com.dyxy.tms.module;

import com.dyxy.tms.R;
import com.dyxy.tms.utils.FragmentSwitchTool;

import android.app.Activity;
import android.app.FragmentManager;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
	
public class MainActivity extends Activity{
	//定义控件
	private LinearLayout tab_index,tab_msg,tab_sign,tab_find,tab_mine;
	private TextView tv_index,tv_msg,tv_sign,tv_find,tv_mine;
	private ImageView iv_index,iv_msg,iv_sign,iv_find,iv_mine;
	//fragment 切换类
	private FragmentSwitchTool tool;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if(VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
		}
		setContentView(R.layout.main_activity);
		//requestWindowFeature(Window.FEATURE_NO_TITLE);
		initView();
		tool = new FragmentSwitchTool(getFragmentManager(), R.id.flContainer);
		tool.setClickableViews(tab_index, tab_msg, tab_sign, tab_find,tab_mine);
        tool.addSelectedViews(new View[]{iv_index, tv_index}).addSelectedViews(new View[]{iv_msg, tv_msg})
        	.addSelectedViews(new View[]{iv_sign, tv_sign}).addSelectedViews(new View[]{iv_find, tv_find}).addSelectedViews(new View[]{iv_mine,tv_mine});
        tool.setFragments(IndexFragment.class, MessageFragment.class, SignFragment.class, FindFragment.class,MineFragment.class);
        
        tool.changeTag(tab_index);
	}
	/**
	 * 
	 * 初始化UI
	 */
	public void initView(){
		tab_index = (LinearLayout) findViewById(R.id.tab_index);
		tab_msg = (LinearLayout) findViewById(R.id.tab_msg);
		tab_sign = (LinearLayout) findViewById(R.id.tab_sign);
		tab_mine = (LinearLayout) findViewById(R.id.tab_mine);
		tab_find = (LinearLayout) findViewById(R.id.tab_find);
		
		tv_index = (TextView) findViewById(R.id.tv_index);
		tv_msg = (TextView) findViewById(R.id.tv_msg);
		tv_sign = (TextView) findViewById(R.id.tv_sign);
		tv_find = (TextView) findViewById(R.id.tv_find);
		tv_mine = (TextView) findViewById(R.id.tv_mine);
		
		iv_index = (ImageView) findViewById(R.id.iv_index);
		iv_msg = (ImageView) findViewById(R.id.iv_msg);
		iv_sign = (ImageView) findViewById(R.id.iv_sign);
		iv_find = (ImageView) findViewById(R.id.iv_find);
		iv_mine = (ImageView) findViewById(R.id.iv_mine);
	}

}
